< previous page page_363 next page >

Page 363
    Dim td As TableDef
    Dim fl As Field
    Dim ix As Index
    Dim rl As Relation
    Dim pr As Property
    '
    Dim strDBName As String
    Dim strTDLookUp As String
    Dim strTDMaster As String
    Dim strIXLookUp As String
    Dim strIXMaster As String
    Dim strRLName As String
    Dim strMsg As String
    '
    ' init vars
    strDBName = App.Path & "\RelDB.mdb"
    strTDLookUp = "ValidUnits"
    strTDMaster = "MasterTable"
    strIXLookUp = "PKUnits"
    strIXMaster = "PKMaster"
    strRLName = "relUnitMaster"
    '
    ' erase old db if it's there
    Kill strDBName
    '
    ' open ws and create db
    Set ws = DBEngine.Workspaces(0)
    Set db = ws.CreateDatabase(strDBName, dbLangGeneral, dbVersion30)
    '
    ' now create the lookup list table & fields
    Set td = db.CreateTableDef(strTDLookUp)
    Set fl = td.CreateField("UnitID", dbText, 10)
    td.Fields.Append fl
    Set fl = td.CreateField("Description", dbText, 50)
    td.Fields.Append fl
    '
    ' now add table to database
    db.TableDefs.Append td
    '
    ' index the new table
    Set ix = td.CreateIndex(strIXLookUp)
    ix.Primary = True
    ix.Required = True
    Set fl = ix.CreateField("UnitID")
    ix.Fields.Append fl
    td.Indexes.Append ix
    '
    ' now create master record table
    Set td = db.CreateTableDef(strTDMaster)
    Set fl = td.CreateField("MasterID", dbText, 20)
    td.Fields.Append fl
    Set fl = td.CreateField("MasterUnitID", dbText, 10)
    td.Fields.Append fl
    '
    ' add index to the master table
continues

 
< previous page page_363 next page >

If you like this book, buy it!